<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%-- <jsp:include page="../inc/browsehappy.jsp" /> --%>
<header class="am-topbar am-topbar-inverse admin-header">
	<script type="text/javascript">
		function doit() {
			var options = {
				success : function(data) {
					clean();
				}
			};

			$('#upload').submitForm(options);
			$('#upload').submit(function() {
				$('#upload').ajaxSubmit(options);
				return false;
			});
		}

		function getM() {
			var val = $('#facExcel').val();
			val = val.substring(val.lastIndexOf('\\') + 1, val.length);
			$('#detail').html(val);
			if (val != "" || val != null) {
				$('#tm').prop('disabled', 'disabled');
			}
		}

		function clean() {
			$('#facExcel').val(null);
			$('#tm').prop('disabled', 'disabled');
			$('#detail').html('点击这里上传文件 ');
		}
	</script>

	<div class="am-topbar-brand">
		<div class="am-topbar-brand am-hide-sm-only">
			<img src="${basePath}assets/i/login/dx.png" style="width: 11rem;"><strong>智能物联平台</strong>
			<small>后台管理系统</small><img src="${basePath}assets/i/login/ht.png"
									  style="width: 11rem;">
		</div>
	</div>
	<button
			class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
			data-am-collapse="{target: '#topbar-collapse'}"
			<c:if test="${role== 3}"> disabled="disabled"</c:if>>
		<span class="am-sr-only">导航切换</span> <span class="am-icon-bars" ></span>
	</button>

	<div class="am-collapse am-topbar-collapse" id="topbar-collapse">

		<ul
				class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">

			<c:if test="${sessionScope.user.roleId != 3}">
				<li><a
						href="http://datav.aliyun.com/share/8d2b8291404a0360b39a0f3af1f6435f"><span
						class="am-icon-connectdevelop"></span>数据监测</a></li>
				<li>
<%--					<a href="${basePath}${sessionScope.user.roleId}/realtime?yczt=on" id="faultHref">--%>
      					<a href="" id="faultHref">
						<span class="am-icon-medkit"></span>告警状态<span id="" class="am-badge am-badge-warning"></span>
					</a>
				</li>
			</c:if>
			<li class="am-dropdown" data-am-dropdown><a
					class="am-dropdown-toggle" data-am-dropdown-toggle
					href="javascript:;"> <span class="am-icon-users"></span>
				${sessionScope.user.realName}<span class="am-icon-caret-down"></span>
			</a> <c:if test="${sessionScope.user.roleId != 3}">
				<ul class="am-dropdown-content">
					<li id=bind><a
							href="${basePath}showCode?keepThis=true&TB_iframe=true&height=200&width=180"
							class="thickbox"><span
							class="am-icon-wechat"></span> 绑定微信</a></li>
					<li id="unbind"><a
							href="javascript:void(0)" onclick="unbind()"><span
							class="am-icon-wechat"></span> 解除绑定</a></li>
					<li><a href="${basePath}logout"><span
							class="am-icon-power-off"></span>退出</a></li>
				</ul>

			</c:if></li>
			<li class="am-hide-sm-only">
				<a href="javascript:;" id="admin-fullscreen">
					<span class="am-icon-arrows-alt"></span>
					<span class="admin-fullText">开启全屏</span>
				</a>
			</li>
		</ul>
	</div>
	<script type="text/javascript">
		if("${sessionScope.user.openId}" === ""){
			$("#unbind").hide();
		}else{
			$("#bind").hide();
		}
	</script>
	<script type="text/javascript">
		function unbind(){
			if(confirm("确定要解绑当前微信？")){
				$.ajax({
					type : 'post',
					dataType : 'json',
					cache : false,
					url : "${basePath}unbindWechat",
					success : function(data) {
						if(data.flag){
							alert("解绑成功");
						}else{
							alert("解绑失败");
						}
					}
				});
			}
		}

		function faultNum1() {
			$.ajax({
				type : 'post',
				dataType : 'json',
				cache : false,
				data : '',
				url : "${basePath}ajaxfaultnum",
				success : function(data) {
					$("#fault").text(data.faultNum);
				}
			});
		}
		window.setTimeout(faultNum1(), 100);
	</script>

	<script type="text/javascript">
		var showPageNum;
		var showPntotal;
		/*此script用于在页面里显示申请门禁开锁权限的数据*/
		function getApply() {
			$.ajax({
				type : 'post',
				dataType : 'json',
				cache : false,
				data : '',
				url : "getdoorapplication.do?pagenumber=" + showPageNum,
				success : function(data) {

					$("#data4apply").html("");

					for (var index = 0; index < data.list.length; index++) {

						var indexTemp = index + (data.applyPageNum - 1)
								* data.applyPageSize + 1;
						$("#data4apply")
								.append(
										"<tr><td>"
										+ indexTemp
										+ "</td><td>"
										+ data.list[index].id.facArea
										+ "</td><td>"
										+ data.list[index].id.facNename
										+ "</td><td>"
										+ data.list[index].id.facDesc
										+ "</td><td>"
										+ data.list[index].id.applicant
										+ "</td><td>"
										+ data.list[index].id.phonenum
										+ "</td><td onclick='applyAgree("
										+ data.list[index].id.eventlogId
										+ ")'><span class='am-btn am-btn-default am-btn-xs am-text-secondary'>同意</span><td></tr>");
					}

					showPageNum = data.applyPageNum;
					showPntotal = data.applyPntotal;
					$("#applyTotal").text(data.applyItemTotal);
					$("#applyTotalPage").text(data.applyPntotal);
					$("#applyPageNumber").text(data.applyPageNum);

				}
			});
		}

		//	window.setTimeout(getApply(),2000);
		//	window.setInterval("getApply()",10000);

		/*下面实现查看临时开锁申请的 分页*/
		function applyUp() {
			if (showPageNum <= 1) {
				showPageNum = 1
			} else {
				showPageNum = showPageNum - 1;
			}
			getApply();
		}

		function applyDown() {
			if (showPageNum < showPntotal) {
				showPageNum = showPntotal
			} else {
				showPageNum = showPageNum + 1;
			}
			getApply();
		}

		/*同意申请时调用此方法*/
		function applyAgree(applyEventlogId) {
			$.ajax({
				type : 'post',
				dataType : 'json',
				cache : false,
				url : "dooragreeapply.do",
				data : {
					"applyEventlogId" : applyEventlogId
				},
				success : function(data) {
					getApply();
				}
			});
		}
	</script>

</header>
<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-2">
	<div class="am-modal-dialog">
		<div class="am-modal-hd">
			批量导入设施 <a href="javascript: void(0)" onclick="clean()"
					  class="am-close am-close-spin" data-am-modal-close>&times;</a>
		</div>
		<div class="am-modal-bd">
			<form action="ajaxuploadExcel.do" id="upload"
				  enctype="multipart/form-data" method="post">
				<a href="javascript:;" class="a-upload"
				   enctype="multipart/form-data"> <input type="file"
														 name="facExcel" id="facExcel" onchange="getM()"
														 accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"><span
						id="detail">点击这里上传文件 </span>
				</a>

				<button onclick="doit()" class="am-btn am-btn-primary"
						style="float: left; margin-left: 10%" id="tm" disabled="disabled">执行导入</button>
			</form>
		</div>
	</div>
</div>